﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WarOfDev.EF;

namespace WarOfDev.Web.ViewModels.MappingToModel
{
    public static class PermissionMapping
    {
        public static void BaseToModel(Permission model, PermissionViewModel vm)
        {
            model.Id = vm.Id;
            model.IsLocked = vm.IsLocked;
            model.CreatedOn = vm.CreatedOn;
            model.CreatedBy = vm.CreatedBy;
            model.ModifiedBy = vm.ModifiedBy;
            model.ModifiedOn = vm.ModifiedOn;
            model.PermissionName = vm.PermissionName;
            model.PermissionValue = vm.PermissionValue;
            model.ModuleId = vm.ModuleId;         

        }

        public static Permission ToModel(this PermissionViewModel vm)
        {
            Permission model = new Permission();

            BaseToModel(model, vm);

            return model;
        }

        public static void ToModel(this PermissionViewModel vm, Permission model)
        {
            BaseToModel(model, vm);
            
        }
    }
}